import 'package:flutter/material.dart';
import 'package:wechat_clone/constants.dart' show AppColors;

enum Device{
  MAC,WIN
}

class Conversation {
  const Conversation ({
    @required this.avatar,//该参数是必须的
    @required this.title,//该参数是必须的
    this.titleColor : AppColors.TitleTextColor ,//该参数 有一个默认值
    this.des, 
    @required this.updateAt,//该参数是必须的
    this.isMute : false,//该参数 有一个默认值
    this.unreadMsgCount : 10,//该参数 有一个默认值
    this.displayDot : false,//该参数 有一个默认值
    this.stick : false,//该参数 有一个默认值
  }) : assert(avatar != null),//断言，如果avatar为null，会在调试阶段进行报错
       assert(title != null),
       assert(updateAt != null);

  final String avatar;//图片
  final String title;//标题
  final int titleColor;//标题颜色
  final String des;//消息内容
  final String updateAt;//消息更新时间
  final bool isMute;//是否勿打扰
  final int unreadMsgCount;//未读消息数量
  final bool displayDot;//是否以小圆点的方式显示未读消息
  final bool stick;//是否置顶

}

const List<Conversation> mockConversations = [
  const Conversation(
    avatar: 'assets/images/ic_file_transfer.png',
    title: '文件传输助手',
    des: '',
    updateAt: '19:56',
    stick: true,
    isMute: true,
  ),
  const Conversation(
    avatar: 'assets/images/ic_tx_news.png',
    title: '腾讯新闻',
    des: '豪车与出租车刮擦 俩车主划拳定责',
    updateAt: '17:20',
    stick: true,
  ),
  const Conversation(
    avatar: 'assets/images/ic_wx_games.png',
    title: '微信游戏',
    titleColor: 0xff586b95,
    des: '25元现金助力开学季！',
    updateAt: '17:12',
  ),
  const Conversation(
    avatar: 'https://randomuser.me/api/portraits/men/39.jpg',
    title: 'savi',
    des: '今晚要一起去吃肯德基吗？',
    updateAt: '17:56',
    isMute: true,
    unreadMsgCount: 0,
  ),
  const Conversation(
    avatar: 'https://randomuser.me/api/portraits/women/40.jpg',
    title: 'Tina Morgan',
    des: '晚自习是什么来着？你知道吗，看到的话赶紧回复我',
    updateAt: '17:58',
    isMute: false,
    unreadMsgCount: 3,
  ),
  const Conversation(
    avatar: 'assets/images/ic_fengchao.png',
    title: '蜂巢智能柜',
    titleColor: 0xff586b95,
    des: '喷一喷，竟比洗牙还神奇！5秒钟还你一个漂亮洁白的口腔。',
    updateAt: '17:12',
  ),
  const Conversation(
    avatar: 'https://randomuser.me/api/portraits/women/46.jpg',
    title: 'hello',
    des: '\u{1f44f}\u{1f605}',
    updateAt: '昨天',
    isMute: false,
    unreadMsgCount: 99,
  ),
  const Conversation(
    avatar: 'https://randomuser.me/api/portraits/men/47.jpg',
    title: '汤姆丁',
    des: '今晚要一起去吃肯德基吗？',
    updateAt: '17:56',
    isMute: true,
    unreadMsgCount: 0,
  ),
  const Conversation(
    avatar: 'https://randomuser.me/api/portraits/women/45.jpg',
    title: 'Tina Morgan',
    des: '晚自习是什么来着？你知道吗，看到的话赶紧回复我',
    updateAt: '17:58',
    isMute: false,
    unreadMsgCount: 3,
  ),
  const Conversation(
    avatar: 'https://randomuser.me/api/portraits/men/57.jpg',
    title: 'Tom',
    des: '今天要去运动场锻炼吗？',
    updateAt: '昨天',
    isMute: false,
    unreadMsgCount: 0,
  ),
  const Conversation(
    avatar: 'https://randomuser.me/api/portraits/men/48.jpg',
    title: '汤姆丁',
    des: '今晚要一起去吃肯德基吗？',
    updateAt: '17:56',
    isMute: true,
    unreadMsgCount: 0,
  ),
  const Conversation(
    avatar: 'https://randomuser.me/api/portraits/women/49.jpg',
    title: 'Tina Morgan',
    des: '晚自习是什么来着？你知道吗，看到的话赶紧回复我',
    updateAt: '17:58',
    isMute: false,
    unreadMsgCount: 1,
  ),
  const Conversation(
    avatar: 'https://randomuser.me/api/portraits/women/50.jpg',
    title: 'Lily',
    des: '今天要去运动场锻炼吗？',
    updateAt: '昨天',
    isMute: false,
    unreadMsgCount: 0,
  ),
];


const Map<String, List<Conversation>> mockConversationData = {
  'deviceInfo': null,
  'conversations': mockConversations,
};

// 一般和后端的数据交互就是将json数据转换为对象
class ConversationPageData {

  const ConversationPageData({
    this.device,
    this.conversations
  });
  final Device device;
  final List<Conversation> conversations;

  //模拟数据
  static mock(){
    return ConversationPageData(device: Device.WIN, conversations: mockConversations);
  }

}